const mongoose = require("mongoose")
const fs = require("fs");
const path = require("path")
const CinemaSchema = new mongoose.Schema({
    name: String, //院线名,
    addr: String, //院线地址,
    image: String, //院线图片
    tel: String, //官方电话
}, {
        versionKey: false,
        timestamps: {
            createdAt: 'createTime',
            updatedAt: 'updateTime'
        } //自动管理修改时间
    })
const Cinema = mongoose.model("Cinema", CinemaSchema)
async function addCinema() {
    const count = await Cinema.countDocuments();
    if (count == 0) {
        const content = fs.readFileSync(path.join(__dirname, "./data/cinema.json")).toString();
        const articles = JSON.parse(content)
        await Cinema.create(articles)
    }
}
addCinema();
module.exports = Cinema;